<?php

require_once 'init.php';

$counter = 0;
$tickets = array();

while ( $counter < 1100 )
{
  $number       = mt_rand( 1, 999999 );
  $number_print = str_repeat ( '0' , 6 - strlen( $number ) ) . (string)$number;

  $octet_1 = substr( $number_print, 0, 3 );
  $octet_2 = substr( $number_print, 3, 3 );
  
  $number_print = $octet_1 . ' ' . $octet_2;
  
  if ( in_array( $number, $tickets ) ) continue;
  
  $tickets[] = $number;
  
  app::$db->execute( "INSERT INTO `tickets` ( `number`, `number_print` ) VALUES ( :number, :number_print )", array( 'number' => $number, 'number_print' => $number_print ) );
  
  $counter++;
}

print 'done';